package cn.gotom.pinggu.action;

import org.apache.commons.lang.StringUtils;

import cn.gotom.core.web.Constants;
import cn.gotom.core.web.action.SupportAction;
import cn.gotom.pinggu.service.DataService;
import cn.gotom.pinggu.vo.Nsrxx;

import com.google.inject.Inject;

/**
 * 选择纳税人Action
 * 
 * @author longjun
 * 
 */
public class TaxpayerAction extends SupportAction
{
	private static final long serialVersionUID = 1L;
	@Inject
	private DataService dataService;
	private Nsrxx nsrxx;
	private String actionmsg;
	private String goingToURL;

	public String list()
	{
		nsrxx = new Nsrxx();
		return Constants.SUCCESS;
	}

	public String input()
	{
		if (StringUtils.isEmpty(nsrxx.getNsrdm()) && StringUtils.isEmpty(nsrxx.getNsrmc()))
		{
			setActionmsg("请输入纳税人代码或名称！");
			return INPUT;
		}
		Nsrxx nsr = null;

		if (StringUtils.isNotEmpty(nsrxx.getNsrdm()))
		{
			nsr = dataService.getNsrxxByNsrdm(nsrxx.getNsrdm());
		}
		else if (StringUtils.isNotEmpty(nsrxx.getNsrmc()))
		{
			nsr = dataService.getNsrxxByNsrdm(nsrxx.getNsrmc());
		}
		if (nsr == null)
		{
			setActionmsg("该纳税人不存在，请输入正确的纳税人信息！");
			return INPUT;
		}
		// String goingToURL = (String) this.getSession().get(Constants.GOING_TO_URL_KEY);
		// if (StringUtils.isNotEmpty(goingToURL))
		// {
		// setGoingToURL(goingToURL);
		// this.getSession().remove(Constants.GOING_TO_URL_KEY);
		// }
		// else
		// {
		// setGoingToURL(Constants.WELCOME);
		// }
		setActionmsg("");
		return SUCCESS;
	}

	public Nsrxx getNsrxx()
	{
		return nsrxx;
	}

	public void setNsrxx(Nsrxx nsrxx)
	{
		this.nsrxx = nsrxx;
	}

	public String getActionmsg()
	{
		return actionmsg;
	}

	public void setActionmsg(String actionmsg)
	{
		this.actionmsg = actionmsg;
	}

	public String getGoingToURL()
	{
		return goingToURL;
	}

	public void setGoingToURL(String goingToURL)
	{
		this.goingToURL = goingToURL;
	}
}
